fimppfandomcom-20200216-history
Paragraphs
A paragraph (A.K.A. function or paragraph) is FiM++'s way of encapsulating code that runs. Very little code (Such as global variable declaration) runs outside paragraphs. Related Phrases Here are the reserved phrases used in paragraphs: * Paragraph Declaration ** ** ** ** ** * Paragraph Returning ** * Paragraph Ending ** * Paragraph Calling ** ** Name Restrictions Each paragraph name has the following restrictions: * Must not contain any keywords (However, operators and literals are okay) * Must not contain any punctuation * Must begin with one non-whitespace, non-literal character * Must end with one non-whitespace character character Freedoms Each paragraph name also has the following freedoms: * There is no hard limit on the length * May have any whitespace character in them * May contain operators that do not share a name with keywords * May contain literals, as long as they are not at the beginning of the name * May contain apostrophes, as they are not punctuation * Encoded in UTF-8 Examples Here are some examples of good paragraph names: * }} ** Paragraph names can have spaces in them. * }} ** Paragraph names don't have to start with "how to". * }} ** Even though is used to declare character literals, it is used in the middle of a name, so it is okay. * }} ** Even though is a literal, FiM++ is case-sensitive, so is valid for paragraph naming. * }} ** Even though is a number literal, it is not at the beginning of the paragraph name Here are some examples of bad paragraph names: * }}}} ** is a keyword, so this will not compile. * }}}} ** " " is an operator, so this will not compile. * Rainbow Dash}}}} ** compiler thinks " " is the end of the paragraph name " ", and doesn't know what to do with the rest * Magic}}}} ** " " 'is an operator and keyword. * }} ** is used to start a character literal (such as , so the compiler sees this as an unclosed character literal. * }} }} ** is always a literal, so it cannot be the beginning of a paragraph name. Additionally, the compiler doesn't know how to handle the rest of the line. Declaration Paragraphs are declared with the text " ", followed by the name of the paragraph and a punctuation. Mane paragraphs start with " ". Return types can be left blank for a void return type, or will follow the paragraph name and the word " " or " . Parameters (values that are sent to the paragraph) follow the return type and the word " " and are separated from each other with " ". Returning In order to return a value from a paragraph, the the phrase " " is used, followed by the returned value, followed by punctuation. Returned values can be paragraphs, variables, or literals. Returned values must be the same type as is specified in the paragraph declaration. Example : }} Closing Paragraphs are closed with the phrase " ", followed by the paragraph's name, followed by a punctuation. Example : }} Calling When used to read, store, or return a value, paragraphs are called in the same context as a variable; simply use the name of a paragraph instead of the name of a variable. Parameters can be specified just like they are declared (using " "). To call a paragraph and ignore its returned value, start a line with " " or " , followed by the paragraph name and any parameters, then the punctuation. * }} * }} Examples Calling a paragraph and ignoring its return value: : }} Storing the return value of a paragraph into a variable after passing the paragraph two parameters: : }} Mane Paragraphs Mane paragraphs are paragraphs that run without being explicitly called by code. They can also be run by being called in the code. When the program is run, each mane paragraph is run once, in order of declaration.